package myfunction

import (
	"io"
	"strconv"
	"strings"
)

type intGen func() int

func (ig intGen) Read(p []byte) (n int, err error) {
	var next int
	next = ig()
	if next > 10000 {
		return 0, io.EOF
	}
	//strNext := fmt.Sprintf("%d", next)
	strNext := strconv.Itoa(next) + " "
	return strings.NewReader(strNext).Read(p)
}

func Fibonacci() func() int {
	a, b := 0, 1
	return func() int {
		a, b = b, a+b
		return a
	}
}

func Fibonacci2() intGen {
	a, b := 0, 1
	return func() int {
		a, b = b, a+b
		return a
	}
}
